This example establishes a stand-alone rdoConnection object, sets its properties and uses the EstablishConnection method to open the connection.
Option Explicit
Dim cn As New rdoConnection
Private Sub rdoConnectionButton_Click()
WorkingLight.Caption = "Connecting"
With cn
.Connect = "DSN=BadServerName;" _
& "UID=;PWD=;DATABASE=WorkDB;"
.LoginTimeout = 20
.CursorDriver = rdUseOdbc
.EstablishConnection _
prompt:=rdDriverNoPrompt, _
Option:=rdAsyncEnable
End With
While .StillConnecting
ToggleLight ' Flash status indicator
DoEvents
Wend
WorkingLight = True ' Show status indicator
WorkingLight.Caption = "Connected"
End Sub
Sub ToggleLight() 'Flashes "Opening" light
WorkingLight = Not WorkingLight
End Sub